<template>
  <div class="home">
    <van-button type="primary" @click="handleRouter('/user')">用户</van-button>
    <van-button type="primary" @click="handleRouter('/project')">方案</van-button>
    <van-button type="primary" @click="handleRouter('/setting')">设置</van-button>
    <van-button type="primary" @click="handleRouter('/apply')" block class="mt-10">应用</van-button>
    <van-button type="primary" block round @click="onLogout">退出登录</van-button>
  </div>
</template>
<script>
import { Dialog } from 'vant';

export default {
  name: 'Home',
  methods: {
    handleRouter(url){
      this.$router.push(url)
    },
    onLogout() {
      Dialog.confirm({
        title: '确认退出登录',
        message: '确定要退出吗？'
      })
        .then(async () => {
          await this.$store.dispatch('user/logout');
          this.$router.push(`/login?redirect=${this.$route.fullPath}`);
        })
        .catch(() => {});
    }
  }
};
</script>
<style lang="less">
.home{
  padding: 100px;
}
</style>
